package top.yihoxu.client;

import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.json.JSONUtil;
import top.yihoxu.entity.User;

/**
 * @Author dth
 * @Date 2024/7/27 12:30
 * @PackageName:top.yihoxu.client
 * @ClassName: NameClient
 * @Description: TODO
 * @Version 1.0
 */
public class NameClient {


    public User invoke(String requestParams, ApiClient apiClient) {
        int rightIndex = requestParams.indexOf("]");
        String params = requestParams.substring(1, rightIndex);
        HttpResponse response = HttpRequest.post("http://localhost:8123/api/name/user")
                .addHeaders(apiClient.getHeadMap(params))
                .body(params)
                .execute();
        String res = response.body();
        User user = new User();
        user.setName(res);
        return user;
    }

}
